<template>
	<view class="carousel-section">
		<u-icon name="volume" color="#2979ff" size="20"></u-icon>
		<!-- 背景色区域 -->
		<swiper class="carousel" circular @change="swiperChange" :autoplay="true" :interval="3000" vertical="true">
			<swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
				@click="navToDetailPage({id:item.id})">
				<view class="swiperItemItemDiv">{{item.title}}</view>
			</swiper-item>
		</swiper>

	</view>
</template>

<script>
	import {
		getNewsBulletin
	} from '@/api/home.js'

	export default {
		name: "noticePage",
		data() {
			return {
				carouselList: []
			};
		},
		created() {
			this.getSlideshow()
		},
		methods: {
			// 获取轮播图数据
			async getSlideshow() {
				let res = await getNewsBulletin()
				if (res.code == 200) {
					this.carouselList = res.data
				}
			},
			//轮播图切换
			swiperChange(e) {
				const index = e.detail.current;
				this.swiperCurrent = index;
			},
			navToDetailPage(id) {

			}
		}
	}
</script>

<style lang="scss">
	.carousel-section {
		overflow: hidden;
		width: 100%;
		height: 60rpx;
		padding: 30rpx;
		display: flex;
		align-items: center;
		gap: 30rpx;

		.carousel {
			width: 100%;
			height: 40rpx;

			.swiperItemItemDiv {
				width: 100%;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
		}
	}
</style>